home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1994 A.D. Software. All Rights Reserved
-
- // OOFTEST10
-
- // this sample uses stream operators to set records
-
- // Simple stream I/O is used to interact with the user.
- #include "oofile.hpp"
-
-
- CLASS_TABLE(dbPeople)
- dbChar LastName, OtherNames;
- // dbLong Salary;
- // dbText Description;
-
- dbPeople() :
- dbTable("People"),
- LastName(39, "Last Name", kIndexed),
- OtherNames(79, "Other Names", kIndexed) //,
- // Salary("Salary", kIndexed),
- // Description("Description")
- {};
- };
-
- dbConnect_ctree theDB;
- dbPeople People;
-
- int main()
- {
- cout << "OOFILE Validation Suite - Test 10\n"
- << "Simple test to demonstrate creating records" << endl
- << "using input streams" << endl;
-
- if (dbConnect::fileExists("ooftst10.db")) {
- theDB.openConnection("ooftst10.db");
- People.deleteAll();
- }
- else {
- theDB.newConnection("ooftst10.db");
- }
-
- // fake setting up an input stream, with known quantities.
- // in normal life, we'd have an input stream straight from a file
- // but we want predictable input so we can use the output for regression testing
-
- ostrstream oss;
- oss << "Dent" << '\t' << "Andy" << endl;
- oss << "Dent" << '\t' << "Trissa" << endl;
-
- istream is(oss.rdbuf()); // normally something like ifstream is("filename");
-
- cout << "Entire database - should be empty" << endl << theDB << endl;
-
- is >> People;
-
- cout << "Entire database - after importing from the stream" << endl << theDB << endl;
-
- cout << "done" << endl;
-
- return EXIT_SUCCESS;
- }